<template>
	<view class="uni-flex uni-column uni-bg-white" 
		style="padding:0 64rpx;height:100%;width: 100%; justify-content:center;align-items:center;text-align:center;">
		<view style="padding: 32rpx 0;">
			<image src="../../static/image/hlk.png" style="width:250rpx;height:259rpx;"></image>
		</view>
		<view style="width:100%;flex-grow:2;">
			<view class="uni-flex uni-row" style="align-items:center;justify-content:center;">
				<text style="color:#181818;font-size:12pt;">账号</text>
				<view style="padding-left:32rpx;width:70%;">
					<uni-easyinput v-model="loginInfo.account"
						placeholder="请输入系统账号或手机号码"></uni-easyinput>
				</view>
			</view>
			<view class="uni-flex uni-row" style="align-items:center;justify-content:center;padding:20rpx 0;">
				<text style="color:#181818;font-size:12pt;">密码</text>
				<view style="padding-left:32rpx;width:70%">
					<uni-easyinput type="password" v-model="loginInfo.password" placeholder="请输入登录密码"></uni-easyinput>
				</view>
			</view>
			<view style="padding:20rpx 20rpx;">
				<button style="background-color:#0958d9;color:#FFFFFF;border-radius:100rpx;"
					@click="onClickLogin">
					<view class="uni-flex uni-row" style="align-items:center;justify-content:center;">
						<view>
							<text>登录</text>
						</view>
					</view>
				</button>
			</view>
			<view v-show="false">
				<button style="background-color:#07C160;color:#FFFFFF;border-radius:100rpx;"
					@click="onClickLogin">
					<view class="uni-flex uni-row" style="align-items:center;justify-content:center;">
						<image src="../../static/image/wechat.png" style="width:60rpx;height:60rpx;"></image>
						<view style="padding-left:24rpx;">
							<text>微信登录</text>
						</view>
					</view>
				</button>
			</view>
			<view style="padding-top:32rpx;font-size:11pt;">
				<view class="uni-flex uni-row" style="justify-content:center;align-items:center;">
					<view>
						<checkbox-group @change="agreeChange">
							<checkbox style="transform:scale(0.8)" :checked="state"/>
						</checkbox-group>
					</view>
					<view>
						<text>我已阅读并同意</text>
					</view>
					<view style="padding:0 12rpx;">
						<navigator url="../protocol/user_protocol">
							<text style="color:#10AEFF;">用户协议</text>
						</navigator>
					</view>
					<view>
						<text>及</text>
					</view>
					<view style="padding:0 12rpx;">
						<navigator url="../protocol/privacy_protocol">
							<text style="color:#10AEFF;">隐私协议</text>
						</navigator>
					</view>
				</view>
				<view>
					<text></text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { API } from "@/util/constant.js";
	import { post, reLaunch2Index } from "@/util/request.js"
	import { wxLogin, login} from "@/util/api.js"
	
	export default {
		data() {
			return {
				state: false,
				loginInfo: {
					account: '',
					password:''
				}
			}
		},
		onLoad() {
			
		},
		methods: {
			agreeChange(e) {
				this.state = !this.state;
			},
			onClickLogin(e) {
				var that = this;
				if (that.loginInfo.account == '') {
					uni.showToast({
						icon: 'none',
						title:"请输入账号"
					});
				} else if (that.loginInfo.password == '') {
					uni.showToast({
						icon: 'none',
						title:"请输入密码"
					});
				} else if (!that.state) {
					uni.showToast({
						icon: 'none',
						title:"请阅读并勾选用户协议及隐私协议"
					});
				} else {
					login(that.loginInfo);
				}
				// uni.login({
				// 	"provider": "weixin",
				// 	"onlyAuthorize": true,
				// 	success: function(event){
				// 		console.log(event)
				// 		var res = wxLogin({
				// 			loginCode: event.code
				// 		});
				// 	},
				// 	fail: function (err) {
				//         // 登录授权失败  
				//         // err.code是错误码
				//     }
				// });
			}
		}
	}
</script>

<style>
page {
	color:#181818;
	height:100%;
	display:flex;
	justify-content:center;
	align-items:center;
	font-size:12pt;
}
</style>
